import hudson.model.*;

pipeline {
    agent any
    parameters {
        string(name: 'BROWSER_TYPE', defaultValue: 'chrome', description: 'Type a browser type, should be chrome/firefox')
        string(name: 'TEST_SERVER_URL', defaultValue: '', description: 'Type the test server url')
        string(name: 'NODE', defaultValue: 'win-anthony-demo', description: 'Please choose a windows node to execute this job.')
    }

    stages {
        stage("Initialization") {
            steps {
                script {
                    browser = BROWSER_TYPE?.trim()
                    test_url = TEST_SERVER_URL?.trim()
                    win_node = NODE?.trim()
                }
            }
        }
        stage("Git Checkout") {
            steps {
                script {
                    node (win_node) {
                        checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://gitee.com/youqianglinux/jenkins_pipeline_study.git']]])
                    }
                }
            }
        }
        stage("Run Selenium Test") {
            steps {
                script {
                    node(win_node) {
                        run_bat = env.WORKSPACE + "\\run.bat"
                        bat (run_bat)
                    }
                }
            }
        }
    }
}